# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gstreamer

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.1
pkgrel=1
pkgdesc="GStreamer Multimedia Framework (mingw-w64)"
arch=('any')
url="http://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
            "intltool"
            "gtk-doc"
            "flex"
            "bison"
            )
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
        "${MINGW_PACKAGE_PREFIX}-libxml2"
        "${MINGW_PACKAGE_PREFIX}-glib2"
        "${MINGW_PACKAGE_PREFIX}-gettext")
options=(!libtool strip staticlibs)
source=("${url}/src/gstreamer/gstreamer-${pkgver}.tar.xz"
        'give-cc-to-gir-scanner.mingw.patch'
        0001-W32-gst-g_memmove-is-deprecated.all.patch)
md5sums=('8f7f47ce762d734476211efbd16e00bd'
         '59215d83b4c39aac03848cc9b4eb3f25'
         '9fa68760d004277f016fb60f0834b223')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/give-cc-to-gir-scanner.mingw.patch
  patch -p1 -i ${srcdir}/0001-W32-gst-g_memmove-is-deprecated.all.patch
  autoreconf -fi
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-introspection \
    --enable-silent-rules \
    --disable-poisoning \
    --disable-gtk-doc \
    --enable-docbook \
    --enable-check \
    --enable-debug
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
